<html>
<head><meta charset="utf-8"><title>clippy lints to CI · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/clippy.20lints.20to.20CI.html">clippy lints to CI</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="210305307"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/clippy%20lints%20to%20CI/near/210305307" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/clippy.20lints.20to.20CI.html#210305307">(Sep 16 2020 at 19:00)</a>:</h4>
<p>we currently <code>deny(warnings)</code> in both the compiler and libs.</p>
<p>I think it would make sense to also forbid some clippy lints, like <code>useless_conversion</code>, see <a href="https://github.com/rust-lang/rust/pull/76757#issuecomment-692991039">https://github.com/rust-lang/rust/pull/76757#issuecomment-692991039</a>.</p>
<p>Is there anything technical stopping us from doing so or does someone prefer to not add additional requirements here?</p>



<a name="210306373"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/clippy%20lints%20to%20CI/near/210306373" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/clippy.20lints.20to.20CI.html#210306373">(Sep 16 2020 at 19:08)</a>:</h4>
<p>is clippy currently run at all on CI?</p>



<a name="210306460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/clippy%20lints%20to%20CI/near/210306460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/clippy.20lints.20to.20CI.html#210306460">(Sep 16 2020 at 19:09)</a>:</h4>
<p>in general I have no problem with running clippy in CI, but if we're thinking of denying the warning it might make sense to uplift the lint from clippy to rustc</p>



<a name="210306629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/clippy%20lints%20to%20CI/near/210306629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/clippy.20lints.20to.20CI.html#210306629">(Sep 16 2020 at 19:10)</a>:</h4>
<p>I personally would prefer moving these lints to rustc, but iirc this is fairly bothersome as it requires t-lang signoff or something</p>



<a name="210306915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/clippy%20lints%20to%20CI/near/210306915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/clippy.20lints.20to.20CI.html#210306915">(Sep 16 2020 at 19:12)</a>:</h4>
<p><span aria-label="shrug" class="emoji emoji-1f937" role="img" title="shrug">:shrug:</span> that seems like an argument to make the process for uplifting lints easier</p>



<a name="210309793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/clippy%20lints%20to%20CI/near/210309793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/clippy.20lints.20to.20CI.html#210309793">(Sep 16 2020 at 19:36)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/122651-general/topic/clippy.20lints.20to.20CI/near/210306629">said</a>:</p>
<blockquote>
<p>I personally would prefer moving these lints to rustc, but iirc this is fairly bothersome as it requires t-lang signoff or something</p>
</blockquote>
<p>Honestly, I don't think that's the primary blocker. With my T-lang hat on, I'd <em>love</em> to see many clippy lints (any without false positives) uplifted into rustc. Other lang team members have expressed the same sentiment, and I think the approval process would be trivial. Someone just needs to port them and submit a PR.</p>



<a name="210309844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/clippy%20lints%20to%20CI/near/210309844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/clippy.20lints.20to.20CI.html#210309844">(Sep 16 2020 at 19:37)</a>:</h4>
<p>In the past, there's been some difficulty because there was an attempt to mass-approve a whole pile of clippy lints, and that generated enough complexity and bikeshedding that it didn't make forward progress.</p>



<a name="210310736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/clippy%20lints%20to%20CI/near/210310736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/clippy.20lints.20to.20CI.html#210310736">(Sep 16 2020 at 19:44)</a>:</h4>
<p>A PR uplifting a lint should be easy to get approved.</p>



<a name="210313708"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/clippy%20lints%20to%20CI/near/210313708" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matthiaskrgr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/clippy.20lints.20to.20CI.html#210313708">(Sep 16 2020 at 20:07)</a>:</h4>
<p>There is also <code>-Wtrivial-casts -Wtrivial-numeric-casts</code> in rustc (allow by default) but it seems very noisy.<br>
<code>RUSTFLAGS="-Wtrivial-casts -Wtrivial-numeric-casts --cap-lints warn" ./x.py check </code> if you are curious</p>



<a name="210442383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/clippy%20lints%20to%20CI/near/210442383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/clippy.20lints.20to.20CI.html#210442383">(Sep 17 2020 at 19:56)</a>:</h4>
<p>+1 to what Josh said.  The RFC was hard because it was trying to decide on something like two dozen lints at once.  But one at a time shouldn't be a problem.</p>



<a name="247064176"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/clippy%20lints%20to%20CI/near/247064176" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Surya <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/clippy.20lints.20to.20CI.html#247064176">(Jul 24 2021 at 08:49)</a>:</h4>
<h3>Noob question alert</h3>
<div class="codehilite"><pre><span></span><code>match sqlx::query!(
        r#&quot;
            INSERT INTO subscriptions (
            id, email, name, subscribed_at
            ) VALUES ($1, $2, $3, $4)
        &quot;#,
        Uuid::new_v4(),
        form.email,
        form.name,
        Utc::now()
    )
</code></pre></div>
<p>Clippy throws error stating that </p>
<p><code>``error: used binding </code>_expr` which is prefixed with an underscore. A leading underscore signals that a binding will not be used<br>
  --&gt; src/routes/subscriptions.rs:31:9<br>
   |<br>
31 |         Utc::now()</p>
<div class="codehilite"><pre><span></span><code>However as you can see, I am not using an underscore for any variable, I am directly using the value.

Is the only way to avoid this linting error is to create a new variable?

How can I avoid the clippy error please suggest?
</code></pre></div>



<a name="247064510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/clippy%20lints%20to%20CI/near/247064510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/clippy.20lints.20to.20CI.html#247064510">(Jul 24 2021 at 08:58)</a>:</h4>
<p>Are you passing <code>-W</code> or <code>-D clippy::pedantic</code>?</p>



<a name="247064551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/clippy%20lints%20to%20CI/near/247064551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/clippy.20lints.20to.20CI.html#247064551">(Jul 24 2021 at 09:00)</a>:</h4>
<p>Maybe add <code>-A clippy::used_underscore_binding</code> or stop using <code>pedantic</code></p>



<a name="247154286"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/clippy%20lints%20to%20CI/near/247154286" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Surya <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/clippy.20lints.20to.20CI.html#247154286">(Jul 26 2021 at 01:03)</a>:</h4>
<p>I want to understand why I am getting this error, there is no unused variable in there though, why am I getting this error?</p>



<a name="247154400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/clippy%20lints%20to%20CI/near/247154400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/clippy.20lints.20to.20CI.html#247154400">(Jul 26 2021 at 01:06)</a>:</h4>
<p>the error probably occurs in the expansion of the <code>query!</code> macro</p>



<a name="247154407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/clippy%20lints%20to%20CI/near/247154407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/clippy.20lints.20to.20CI.html#247154407">(Jul 26 2021 at 01:06)</a>:</h4>
<p>this is a clippy bug, it should not flag issues in macros you don't control</p>



<a name="247156018"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/clippy%20lints%20to%20CI/near/247156018" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Surya <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/clippy.20lints.20to.20CI.html#247156018">(Jul 26 2021 at 01:48)</a>:</h4>
<p>Thank you! <br>
<code>cargo clippy</code> in my local passes without throwing any error though.</p>
<p>In the CI though we seem to install <code>rustup cargo add clippy</code>, we check linting changes through a binary. I think the binary is not up to date <span aria-label="head bandage" class="emoji emoji-1f915" role="img" title="head bandage">:head_bandage:</span> </p>
<p>I couldn't find the source code of the binary too, no idea what is happening.</p>
<p>Anyways, I don't think this is a clippy bug.</p>
<p>But thanks <span class="user-mention" data-user-id="211727">@Jonas Schievink  [he/him]</span>  it helped me understand the issue. <span aria-label="pray" class="emoji emoji-1f64f" role="img" title="pray">:pray:</span></p>



<a name="247164383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/clippy%20lints%20to%20CI/near/247164383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/clippy.20lints.20to.20CI.html#247164383">(Jul 26 2021 at 05:20)</a>:</h4>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/122651-general/topic/clippy.20lints.20to.20CI/near/210310736">said</a>:</p>
<blockquote>
<p>A PR uplifting a lint should be easy to get approved.</p>
</blockquote>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> took one over for me in april (which I had initially filed in dec 2020), and it still hasn't landed (although it seems very close?). even before them it kind felt like a surprising amount of work at the time, and... i don't envy him the amount of work it took since then to get it landable.</p>
<p>I also don't think it was particularly an example of a messy clippy lint or anything, just it seems that theres a big difference between whats acceptable for clippy and in-tree lints...</p>



<a name="247166418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/clippy%20lints%20to%20CI/near/247166418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Surya <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/clippy.20lints.20to.20CI.html#247166418">(Jul 26 2021 at 06:08)</a>:</h4>
<p><span class="user-mention" data-user-id="209168">@Thom Chiovoloni</span>  that is tricky!<br>
What does in-tree lints mean?<br>
Is it advisable to skip clippy linting for some cases? From your message looks like it is advisable to use clippy linting <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<a name="247167835"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/clippy%20lints%20to%20CI/near/247167835" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/clippy.20lints.20to.20CI.html#247167835">(Jul 26 2021 at 06:36)</a>:</h4>
<p><span class="user-mention silent" data-user-id="379674">Surya</span> <a href="#narrow/stream/122651-general/topic/clippy.20lints.20to.20CI/near/247166418">said</a>:</p>
<blockquote>
<p>What does in-tree lints mean?</p>
</blockquote>
<p>In-tree lints are compiler warnings, and sometimes it's desirable to move them from <code>clippy</code> to <code>rustc</code>. This thread was originally about running <code>clippy</code> on the compiler itself.</p>



<a name="247167918"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/clippy%20lints%20to%20CI/near/247167918" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/clippy.20lints.20to.20CI.html#247167918">(Jul 26 2021 at 06:38)</a>:</h4>
<p><span class="user-mention silent" data-user-id="379674">Surya</span> <a href="#narrow/stream/122651-general/topic/clippy.20lints.20to.20CI/near/247156018">said</a>:</p>
<blockquote>
<p>Anyways, I don't think this is a clippy bug.</p>
</blockquote>
<p>It's certainly a clippy bug. <a href="https://rust-lang.github.io/rust-clippy/master/#used_underscore_binding">https://rust-lang.github.io/rust-clippy/master/#used_underscore_binding</a> says:</p>
<blockquote>
<p>The lint does not work properly with desugaring and macro [sic], it has been allowed in the mean time.</p>
</blockquote>
<p>So you're either passing <code>-W clippy::pedantic</code> or you're using an old version of clippy.</p>



<a name="247170112"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/clippy%20lints%20to%20CI/near/247170112" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Surya <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/clippy.20lints.20to.20CI.html#247170112">(Jul 26 2021 at 07:16)</a>:</h4>
<p>hmm okay,  now I can understand.<br>
In local too when I try with <code>cargo clippy -- -W clippy::pedantic</code> I am able to reproduce these locally too.<br>
thanks for the clarification</p>



<a name="247194283"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/clippy%20lints%20to%20CI/near/247194283" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/clippy.20lints.20to.20CI.html#247194283">(Jul 26 2021 at 12:19)</a>:</h4>
<p><span class="user-mention silent" data-user-id="209168">Thom Chiovoloni</span> <a href="#narrow/stream/122651-general/topic/clippy.20lints.20to.20CI/near/247164383">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/122651-general/topic/clippy.20lints.20to.20CI/near/210310736">said</a>:</p>
<blockquote>
<p>A PR uplifting a lint should be easy to get approved.</p>
</blockquote>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> took one over for me in april (which I had initially filed in dec 2020), and it still hasn't landed (although it seems very close?). even before them it kind felt like a surprising amount of work at the time, and... i don't envy him the amount of work it took since then to get it landable.</p>
<p>I also don't think it was particularly an example of a messy clippy lint or anything, just it seems that theres a big difference between whats acceptable for clippy and in-tree lints...</p>
</blockquote>
<p>well, I also decided to rewrite half of it to use diagnostic items :P so I had to fix some bugs and performance regressions from that. The latest test failure is because not all platforms have atomics, which shouldn't affect any lint other than this one.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>